package com.dmai.capacity.platform.user.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dmai.capacity.platform.common.model.OauthUser;
import com.dmai.capacity.platform.db.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 客户表 Mapper 接口
 */
@Mapper
public interface OauthUserMapper extends BaseMapper<OauthUser> {
	
	/**
	 * 数据脱敏
	 * @param user
	 */
	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("insert into oauth_user( username,password,mobile,type,create_time,update_time) values (#{username,typeHandler=com.dmai.capacity.platform.db.typehandler.CryptTypeHandler},  #{password,typeHandler=com.dmai.capacity.platform.db.typehandler.CryptTypeHandler}, #{mobile,typeHandler=com.dmai.capacity.platform.db.typehandler.CryptTypeHandler}, #{type}, #{createTime}, #{updateTime})")
	void insertEnc(OauthUser user);

	/**
	 * 脱敏查询
	 * @param page
	 * @param user
	 * @return
	 */
    List<OauthUser> selectListEnc(Page<OauthUser> page, OauthUser user);
	
    /**
     * 分页查询用户列表
     * @param page
     * @param params
     * @return
     */
    List<OauthUser> findList(Page<OauthUser> page, @Param("params") Map<String, Object> params);
}
